package com.example.stuwork.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 随堂测试实体类
 * 对应 quiz 表
 */
public class Quiz implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 测试ID
     */
    private Long quizId;

    /**
     * 课程编码
     */
    private String courseId;

    /**
     * 班级ID
     */
    private Long classId;

    /**
     * 发布教师工号
     */
    private String teacherId;

    /**
     * 测试标题
     */
    private String title;

    /**
     * 测试描述
     */
    private String description;

    /**
     * 状态：0-未开始，1-进行中，2-已结束
     */
    private Integer status;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 非数据库字段：测试题目列表
     */
    private List<QuizQuestion> questions;

    /**
     * 非数据库字段：课程名称
     */
    private String courseName;

    /**
     * 非数据库字段：班级名称
     */
    private String className;

    /**
     * 非数据库字段：教师姓名
     */
    private String teacherName;

    /**
     * 无参构造函数
     */
    public Quiz() {
    }

    /**
     * 全参构造函数
     */
    public Quiz(Long quizId, String courseId, Long classId, String teacherId, String title,
                String description, Integer status, Date createTime, Date updateTime) {
        this.quizId = quizId;
        this.courseId = courseId;
        this.classId = classId;
        this.teacherId = teacherId;
        this.title = title;
        this.description = description;
        this.status = status;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    /**
     * 用于创建测试的构造函数
     */
    public Quiz(String courseId, Long classId, String teacherId, String title, String description) {
        this.courseId = courseId;
        this.classId = classId;
        this.teacherId = teacherId;
        this.title = title;
        this.description = description;
        this.status = 0; // 默认未开始
    }

    // Getters and Setters
    public Long getQuizId() {
        return quizId;
    }

    public void setQuizId(Long quizId) {
        this.quizId = quizId;
    }

    public String getCourseId() {
        return courseId;
    }

    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }

    public Long getClassId() {
        return classId;
    }

    public void setClassId(Long classId) {
        this.classId = classId;
    }

    public String getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<QuizQuestion> getQuestions() {
        return questions;
    }

    public void setQuestions(List<QuizQuestion> questions) {
        this.questions = questions;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getTeacherName() {
        return teacherName;
    }

    public void setTeacherName(String teacherName) {
        this.teacherName = teacherName;
    }

    @Override
    public String toString() {
        return "Quiz{" +
                "quizId=" + quizId +
                ", courseId='" + courseId + '\'' +
                ", classId=" + classId +
                ", teacherId='" + teacherId + '\'' +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", status=" + status +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                '}';
    }
} 